package com.forum.core.util;

import java.util.Properties;

import org.springframework.core.io.support.PropertiesLoaderUtils;

/**
 * @Company <Jinher Technology Development Company LTD.>
 * @Project <Jinher Collaboration Suite>
 * @version <1.0>
 * @Author <yangzq>
 * @Date <Nov 11, 2009>
 * @description < 资源文件读取类 >
 */
public class ResourceServiceConfig {

	private static Properties properties;
	private static String jdbcURL;
	private static String jdbcUserName;
	private static String jdbcPassword;
	private static String jdbcDriverClassName;

	private static String bitAnswerUrl;
	private static String bitAnswerSn;

	static {
		try {
			// 获得配置文件properties
			properties = PropertiesLoaderUtils.loadAllProperties("config.properties");

			// 获取资源属性值
			jdbcURL = properties.getProperty("jdbc.url");
			jdbcUserName = properties.getProperty("jdbc.username");
			jdbcPassword = properties.getProperty("jdbc.password");
			jdbcDriverClassName = properties.getProperty("jdbc.driverClassName");

			bitAnswerUrl = properties.getProperty("bitanswer.url");
			bitAnswerSn = properties.getProperty("bitanswer.sn");

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static String getValue(String key) {
		return properties.getProperty(key);
	}

	// --------------------------------------------------------------------
	public static Properties getProperties() {
		return properties;
	}

	public static void setProperties(Properties properties) {
		ResourceServiceConfig.properties = properties;
	}

	public static String getJdbcURL() {
		return jdbcURL;
	}

	public static void setJdbcURL(String jdbcURL) {
		ResourceServiceConfig.jdbcURL = jdbcURL;
	}

	public static String getJdbcUserName() {
		return jdbcUserName;
	}

	public static void setJdbcUserName(String jdbcUserName) {
		ResourceServiceConfig.jdbcUserName = jdbcUserName;
	}

	public static String getJdbcPassword() {
		return jdbcPassword;
	}

	public static void setJdbcPassword(String jdbcPassword) {
		ResourceServiceConfig.jdbcPassword = jdbcPassword;
	}

	public static String getJdbcDriverClassName() {
		return jdbcDriverClassName;
	}

	public static void setJdbcDriverClassName(String jdbcDriverClassName) {
		ResourceServiceConfig.jdbcDriverClassName = jdbcDriverClassName;
	}

	public static String getBitAnswerUrl() {
		return bitAnswerUrl;
	}

	public static void setBitAnswerUrl(String bitAnswerUrl) {
		ResourceServiceConfig.bitAnswerUrl = bitAnswerUrl;
	}

	public static String getBitAnswerSn() {
		return bitAnswerSn;
	}

	public static void setBitAnswerSn(String bitAnswerSn) {
		ResourceServiceConfig.bitAnswerSn = bitAnswerSn;
	}

	public static void main(String[] args) {
		System.out.println(getJdbcPassword());
	}

}
